package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Message;
import com.api.shopapi.mapper.MessageMapper;
import com.api.shopapi.service.MessageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("MessageServiceImplOne")
public class MessageServiceImpl implements MessageService {

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public int insert(Message message){
        return messageMapper.insert(message);
    }

    @Override
    public int deleteByMessageCode(String messageCode){
        return messageMapper.deleteByMessageCode(messageCode);
    }

    @Override
    public int updateByMessageCode(Message message){
        return messageMapper.updateByMessageCode(message);
    }


    @Override
    public Message getByMessageCode(String messageCode) { return messageMapper.getByMessageCode(messageCode); }

    @Override
    public List<Message> getList() {
        return messageMapper.getList();
    }


    @Override
    public PageInfo<Message> getPageInfo(int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<Message> listMessage = messageMapper.getList();
        PageInfo<Message> pageInfo = new PageInfo<Message>(listMessage);
        return pageInfo;
    }
}